function trArrServiceTriMetCreateUpdaters(arrivals_object, service_requests, updaters) {
	
	var max_stops_per_request = 10;

	// TriMet allows a max of 10 stops in one request, so split things up into multiple updater objects if need be
	while (service_requests.length > 0) {
		if (service_requests.length > max_stops_per_request) {
			updaters.push(new trArrTriMetUpdater(service_requests.slice(0,max_stops_per_request),arrivals_object));
			service_requests = service_requests.slice(max_stops_per_request);
		} else {
			updaters.push(new trArrTriMetUpdater(service_requests,arrivals_object));
			service_requests = [];
		}
	}

}

function trArrTriMetUpdater(service_requests,arrivals_object) {
	
	var updater = this;
	
	// every updater object needs to maintain a queue
	this.arrivals_queue = [];
	
	var stop_id_list = [];
	for (var i = 0; i < service_requests.length; i++){
		stop_id_list.push(service_requests[i].stop_id);
	}
	var stop_string = stop_id_list.join(',');
	this.url = "http://developer.trimet.org/ws/V1/arrivals/?locIDs="+stop_string+"&appID=828B87D6ABC0A9DF142696F76&json=true";
	
	this.arrivals = function() {
		return this.arrivals_queue;
	}
	
	this.trArrTriMetRequestLoop = function() {
		
		jQuery.ajax({
		  url: updater.url,
		  dataType: 'jsonp',
		  cache: false,
		  success: function(data) {
		  	var local_queue = [];
		  	var update_time = new Date().getTime();
				for (var i = 0; i < data.resultSet.arrival.length; i++){ 
					var arrival = data.resultSet.arrival[i];
					//debug_alert(arrival);
					var entry = {};
					var entry_date = new Date();
					entry_date.setISO8601(arrival.scheduled);
					entry.arrivalTime = entry_date.getTime(); // seconds since epoch for arrival
					if (arrival.status == "scheduled") {
						entry.type = "scheduled";
					} else {
						entry.type = "estimated";
					}
					entry.headsign = arrival.fullSign;
					entry.stop_id = arrival.locid;
					var stop_data = trStopCache().stopData('TriMet',entry.stop_id);
					entry.stop_data = copyStopData(stop_data);
					entry.route_id = arrival.route;
					for (var j = 0; j < stop_data.routes.length; j++){
						if (stop_data.routes[j].route_id == entry.route_id) {
							entry.route_data = stop_data.routes[j];
						}
					}
					entry.agency = "TriMet";
					entry.avl_agency = "TriMet";
					entry.alerts = ""; // need to figure this out later
					entry.last_updated = update_time;
					local_queue.push(entry);
				}
				
				// now copy to externally visble queue, making sure we're not in the middle of a query
				updater.arrivals_queue = local_queue;
				//jQuery('#arrivals_log_area').append("<PRE>"+dump(updater.arrivals_queue)+"</PRE>");
				
		  }
		});
	}
	
	updater.trArrTriMetRequestLoop(); // first time immediately
	setInterval(updater.trArrTriMetRequestLoop,60*1000);

}

function copyStopData(data) {
	var out = {};
	for (var element in data) {
		// strip it down to just the GTFS elements
		if (element != 'routes' && element != 'geometry' && element != 'doc_type' && element.substring(0,1) != '_') {
			out[element] = data[element]
		}
	}
	return out;
}